Ext.define('PJ.view.registrationmanagement.UpdateUser', {
    extend: 'AM.default.DefaultWindowForm',
    requires: ['AM.default.jsonp.DefaultSubmitJsonp'
               ],
    
    modal: true,// 开启不允许点击其他组件
    frame: true,
    notEdit: true,
    isSame: false,
    isEdit: null,

    initComponent: function(){
    	var me = this;
    	this.items = [{
    		xtype: "container",
    		layout: 'column',
    		width: 400,
            collapsible: false, //显示三角
            defaults: {
    			xtype: 'textfield',
            	labelAlign: 'right',
            	labelWidth: 65,
            	allowBlank: true, // 显示红框是否必填,默认显示
            	readOnly: true,
            	padding: '5 0 0 0',
            	columnWidth: .5
            },
            items: [{
            	fieldLabel: '<span style="color:red;">*</span>姓名',
            	name: 'userName',
            	readOnly: false,
            	allowBlank: false,
            	maxLength: 10,
            	listeners: {
                	change: function(textField){
                		if(textField.getValue() && textField.getValue().length >= 10){
                			Orchid.alert('提示','该输入项最多输入10个字符！');
                		}
                	}
                }
            }, {
    			fieldLabel: '学员帐号',
    			name: 'loginId'
    		}, {
    			fieldLabel: '所属单位',
    			name: 'deptName',
            	columnWidth: 1
    		}, {
    			xtype: 'hidden',
    			name: 'userid'
    		}]
    	}];
		this.buttons = [{
            text: '确定',
            scope: this,
            handler: function(button, event){
                var win = button.up('window');
            	var form = win.down('form');
            	var baseForm = form.getForm();
            	if (!baseForm.isValid()) {
            		return;
            	}
            	if(gj_onlineLearning_constant.loadType == "jsonp"){
            		form.getForm().doAction('submitJsonp',{
            			submitEmptyText:false,
            			url: me.grid.store.updateUrl,
            			params: {},
            			success: function(f, action){
            				if (action.result.success) {
            					Ext.Msg.alert('消息', "更新成功！", function(){
            						win.close();
            						me.grid.store.reload();
            					});
            				}
            			},
            			failure: function(f, action){
            				if (action.result) {
            					Ext.Msg.alert('错误', action.result.msg || "操作失败!");
            				}
            			}
            		});
            	}else if(gj_onlineLearning_constant.loadType == "ajax"){
            		win.submit({
            			submitEmptyText:false,
            			url: me.grid.store.updateUrl,
            			params: {},
            			success: function(f, action){
            				if (action.result.success) {
            					Ext.Msg.alert('消息', '更新成功！', function(){
            						win.close();
            						me.grid.store.reload();
            					});
            				}
            			},
            			failure: function(f, action){
            				if (action.result) {
            					Ext.Msg.alert('错误', action.result.msg || "操作失败!");
            				}
            			}
            		});
            	}
            }
        }, {
            text: '取消',
            scope: this,
            handler: function(button, event){
            	button.up('window').close();
            }
        }];
        me.callParent(arguments);
    },
    listeners: {
    	close: function(){
    		this.grid.store.load();
    	}
    }
});
